<template> 
	<view class="collect_goods">
		<view @tap="goUrl(item.id,item.status)" class="type_1" v-for="(item, index) in collect_data" :key="index">
			<image v-if="item.status == 0" class="status-icon" src="../../../static/images/jewel/statue-icon.png"></image>
			<view class="collg_left">
				<image class="img" :src="item.thumb" mode="aspectFit"></image>
			</view>
			<view class="collg_right">
				<view class="coll_title f-two-ellipsis">
					{{ item.goods_name }}
				</view>
				<view class="price">
					<text class="prize_fo">¥</text>
					{{ item.shop_price }}
				</view>
				<view class="del-icon" @tap="deleteTap(item.id)">
					<image src="../../../static/icons/search-delete.png" ></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import jewel from '@/common/common_zb.js';
export default {
	data() {
		return {
			collect_data: [], //　产品的信息
			bIsShowLoading: false,
			page: 1,
			totalPages: 1,
			loadtype: 'normal',
			search_data: {
				page: this.page
			}
		};
	},
	// 上拉加载
	onReachBottom() {
		this.loadMore()
	},
	methods: {
		get_collect_list(search_data) {
			let that = this;
			if (that.page <= that.totalPages) {
				that.bIsShowLoading = true;
				jewel.get('member/get_collect_list', search_data, true, function(res) {
					let resdata = res.data;
					that.bIsShowLoading = false;
					if (resdata.code == '-1') {
						jewel.showToast(resdata.msg, 1500);
					} else {
						if (that.loadtype == 'plus') {
							that.collect_data = that.collect_data.concat(resdata.data.data);
						} else {
							that.collect_data = resdata.data.data;
							that.totalPages = resdata.data.total_pages;
							uni.stopPullDownRefresh();
						}
					}
				});
			}
		},
		deleteTap(goods_id){
			let that = this
			jewel.get('goods/add_coll', {goods_id: goods_id}, false, function (res){
				let resdata = res.data;
				jewel.showToast(resdata.msg, 1000);
				setTimeout(()=>{
					that.collect_data = []
					that.get_collect_list({ page: 1 })
				},1000)
				
			})
		},
		loadMore(){
			this.page++;
			this.search_data.page = this.page;
			this.get_collect_list(this.search_data);
		},
		goUrl(id,status){
			if(status == 1){
				uni.navigateTo({
					url:'/pages/jewel/goods/show?goods_id='+id
				})
			}
		}
	},
	onLoad() {
		this.get_collect_list({ page: 1 });
		
	}
};
</script>

<style>
	page{
  background: #EFEFEF
}

.collactive{
	color: #bea374 !important; 
	border-bottom: 2rpx solid #bea374;
  height: 78rpx;
}
.collect_goods{
	overflow: hidden;
	background-color: #fff;
}
.collect_goods .type_1{
	width: 100%;
	overflow: hidden;
	padding: 22rpx;
	border-top: 1rpx solid #e4e4e4;
	position: relative;
	height: 100%;
	display: flex;
	align-items: flex-start;
}
.collg_left{
	width: 30%;
	height: 163rpx;
}
.collg_left image{
	width: 100%;
	height: 100%
}
.collg_right{
	width: 65%;
	overflow: hidden;
}

.coll_title{
	box-sizing: border-box;
	padding-left: 18rpx;
	font-size: 30rpx;
	color: #383838;
	overflow: hidden;
	width: 100%;
	height: 90rpx;
	line-height: 45rpx;
}

.del-icon{
  width: 30rpx;
  height: 30rpx;
  text-align: center;
  position: absolute;
  bottom: 44rpx;
  right: 80rpx;
  z-index: 9;
}
.del-icon image{
	width: 100%;
	height: 100%;
	display: block;
}

.price{
	color:#bea374;
	font-size:36rpx;
	line-height: 30rpx;
	margin-left: 18rpx;
	margin-top: 20rpx;
}
.prize_fo{
	font-size:28rpx;
	margin-right: 4rpx;
}

.status-icon{
	position: absolute;
	left: 0;
	top: 0;
	width: 135rpx;
	height: 135rpx;
	z-index: 2;
}


</style>
